# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.next = None
from help_class import ListNode


class Solution(object):

    def reverseList(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        if head is None:
            return head
        fake = ListNode(-1)
        fake.next = head
        run = head.next
        head.next = None
        while run is not None:
            temp = run.next
            run.next = fake.next
            fake.next = run
            run.next = None
            run = temp
        return fake.next
